﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq.Mapping;
using System.Xml.Linq;


namespace Domain {
    [Table(Name = "Product")]
    public class Product {        

        [Column(IsPrimaryKey = true, IsDbGenerated = true, AutoSync = AutoSync.OnInsert)]
        public int ID { get; set; }

        [Column]
        public string Name { get; set; }

        [Column]
        public string Description { get; set; }

        [Column]
        public decimal Price { get; set; }

        public static explicit operator Product(XElement xElem) {
            if (xElem == null) return null;

            return new Product() {
                ID = (int)xElem.Attribute("ID"),
                Name = (string)xElem.Attribute("Name"),
                Description = (string)xElem.Attribute("Description"),
                Price = (decimal)xElem.Attribute("Price")

            };
        }
    }

    
}
